package 设计模式.行为模式.模板模式.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import 设计模式.行为模式.模板模式.*;

/**
 * @author lchenglong
 * @date 2024/1/26
 */
@Service
public class SMSLoginServiceImpl extends LoginTemplate {
    private UserDao userDao;

    @Autowired
    public SMSLoginServiceImpl(UserDao userDao) {
        super(userDao);
        this.userDao=userDao;
    }

    @Override
    public LoginTypeEnum getType() {
        return LoginTypeEnum.SMS;
    }

    @Override
    public Result doLogin(UserInfo userInfo, String smsCode) {
        //验证码是否正确
        String code=userDao.querySmsCode(userInfo.getUserName());
        if(!code.equals(smsCode)){
            return new Result("004","验证码错误",null);
        }else{
            return new Result("200","登录成功",null);
        }

    }
}
